import os
def dir_size(dir1):
    sum=0
    dlist=os.listdir(dir1)
    for f in dlist:
        file1 = os.path.join(dir1, f)
        if os.path.isfile(file1):
            print(file1)
            print('文件的字节数是：',os.path.getsize(file1))
            sum=sum+int(os.path.getsize(file1))
        if os.path.isdir(file1):
            dir_size(file1)
    return sum

print('文件的总字节数是：',dir_size('C:/Users/\\tangyiru/PycharmProjects/csdn1/newcsdn1'))